/**
 * 
 */
package kr.co.insoft.publicmesh.controller.rest;

import java.util.Collection;
import java.util.List;

import kr.co.insoft.core.service.driver.api.DriverApiService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author skpark
 * 
 */
@RestController
@RequestMapping(value = "rest/driver/api", method = RequestMethod.GET, produces = {
		"application/xml", "application/json" })
@ResponseStatus(HttpStatus.OK)
public class RestDriverApiController {

	@Autowired
	DriverApiService driverApiService;

	@RequestMapping(value = "getRegionListByVender")
	public Collection<?> getRegionListByVender(
			@RequestParam(value = "venderid") String venderid,
			@RequestParam(value = "accessKey") String accessKey,
			@RequestParam(value = "secretKey") String secretKey)
			throws Exception {
		return driverApiService.getRegionListByVender(venderid, accessKey,
				secretKey);
	}

	@RequestMapping(value = "getZoneListByRegion")
	public Collection<?> getZoneListByRegion(
			@RequestParam(value = "venderid", required = false) String venderid,
			@RequestParam(value = "regionSeq", required = false) String regionSeq,
			@RequestParam(value = "accessKey", required = false) String accessKey,
			@RequestParam(value = "secretKey", required = false) String secretKey)
			throws Exception {
		return driverApiService.getZoneListByRegion(venderid, regionSeq,
				accessKey, secretKey);
	}

	@RequestMapping(value = "getSecurityGroupListByRegion")
	public Collection<?> getSecurityGroupListByRegion(
			@RequestParam(value = "venderid", required = false) String venderid,
			@RequestParam(value = "regionSeq", required = false) String regionSeq,
			@RequestParam(value = "accessKey", required = false) String accessKey,
			@RequestParam(value = "secretKey", required = false) String secretKey)
			throws Exception {
		return driverApiService.getSecurityGroupListByRegion(venderid,
				regionSeq, accessKey, secretKey);
	}

	@RequestMapping(value = "getKeyPairListByRegion")
	public Collection<?> getKeyPairListByRegion(
			@RequestParam(value = "venderid", required = false) String venderid,
			@RequestParam(value = "regionSeq", required = false) String regionSeq,
			@RequestParam(value = "accessKey", required = false) String accessKey,
			@RequestParam(value = "secretKey", required = false) String secretKey)
			throws Exception {
		return driverApiService.getKeyPairListByRegion(venderid, regionSeq,
				accessKey, secretKey);
	}

	@RequestMapping(value = "getSecurityGroupRules")
	public List<?> getSecurityGroup(
			@RequestParam(value = "venderid", required = false) String venderid,
			@RequestParam(value = "regionSeq", required = false) String regionSeq,
			@RequestParam(value = "securityGroupid", required = false) String securityGroupid,
			@RequestParam(value = "accessKey", required = false) String accessKey,
			@RequestParam(value = "secretKey", required = false) String secretKey)
			throws Exception {
		return driverApiService.getSecurityGroup(venderid, regionSeq,
				securityGroupid, accessKey, secretKey);
	}

	@RequestMapping(value = "getMyImages")
	public Collection<?> getMyImages(@RequestParam String connectionid)
			throws Exception {
		return driverApiService.getMyImages(connectionid);
	}

	@RequestMapping(value = "getHardwareProfiles")
	public Collection<?> getHardwareProfiles(@RequestParam String connectionid)
			throws Exception {
		return driverApiService.getHardwareProfiles(connectionid);
	}
}
